﻿using B.S.Data.MES.API.Applications.BaseData.Command.BOMCommand;
using B.S.Domain.BasicData.MaterialManagement.Product_material;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.BaseData.CommandHandlers.BOMCommandHandlers
{
    public class ShowProductMaterialCommandHandler : IRequestHandler<ShowProductMaterialCommand, APIRequst<List<Product_material>>>
    {
        private readonly IBaseRepository<Product_material> _productRepository;
        public ShowProductMaterialCommandHandler(IBaseRepository<Product_material> productRepository)
        {
            _productRepository = productRepository;
        }
        public Task<APIRequst<List<Product_material>>> Handle(ShowProductMaterialCommand request, CancellationToken cancellationToken)
        {
            var code = _productRepository.GetAll();
            return Task.FromResult(new APIRequst<List<Product_material>> {
            
            Data=code.ToList(),
            Code=RequstCode.成功,
            Msg=RequstCode.成功.ToString()
            });
        }
    }
}
